<%--
  Created by IntelliJ IDEA.
  User: LHC
  Date: 2021/10/29
  Time: 22:26
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>书籍列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 Bootstrap -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>

<div class="container">

    <div class="row clearfix">
        <div class="col-md-12 column">
            <div class="usersPageInfo-header">
                <h1>
                    <small>书籍列表 —— 显示所有书籍</small>
                </h1>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-md-4 column">
            <a class="btn btn-primary" href="${pageContext.request.contextPath}/book/toAddBook">新增</a>
        </div>
    </div>

    <div class="row">
        <div class="col-md-2 column">
            <a class="btn btn-primary" href="${pageContext.request.contextPath}/logout">注销</a>
        </div>
    </div>

    <div class="row clearfix">
        <div class="col-md-12 column">
            <table class="table table-hover table-striped">
                <thead>
                <tr>
                    <th>书籍编号</th>
                    <th>书籍名字</th>
                    <th>书籍数量</th>
                    <th>书籍详情</th>
                    <th>操作</th>
                </tr>
                </thead>

                <tbody>
                <%--varStatus="vs"这个是设置是序号从1开始，序号不等于id--%>
                <%--<c:forEach var="book" items="${requestScope.get('usersPageInfo')}">--%>
                <c:forEach items="${usersPageInfo.list}" var="book" varStatus="vs">
                    <tr>
                        <td>${book.getBookID()}</td>
                        <td>${book.getBookName()}</td>
                        <td>${book.getBookCounts()}</td>
                        <td>${book.getDetail()}</td>
                        <td>
                            <a href="${pageContext.request.contextPath}/book/toUpdateBook?id=${book.getBookID()}">更改</a> |
                            <a href="${pageContext.request.contextPath}/book/del/${book.getBookID()}">删除</a>
                        </td>
                    </tr>
                </c:forEach>
                </tbody>
            </table>
            <div align="center">
                <font size="2">第
                    ${usersPageInfo.pageNum} 页</font> <a href="queryPages?page=1" rel="external nofollow" rel="external nofollow" >首页</a>
                <c:choose>
                    <c:when test="${usersPageInfo.pageNum - 1 > 0}">
                        <a href="queryPages?page=${usersPageInfo.pageNum - 1}" rel="external nofollow" style="color: red">上一页</a>
                    </c:when>
                    <c:when test="${usersPageInfo.pageNum - 1 <= 0}">
                        <a href="queryPages?page=1" rel="external nofollow" rel="external nofollow">上一页</a>
                    </c:when>
                </c:choose>
                <c:choose>
                    <c:when test="${usersPageInfo.total==0}">
                        <a href="queryPages?page=${usersPageInfo.pageNum}" rel="external nofollow" rel="external nofollow" >下一页</a>
                    </c:when>
                    <c:when test="${usersPageInfo.pageNum + 1 < usersPageInfo.total}">
                        <a href="queryPages?page=${usersPageInfo.pageNum + 1}" rel="external nofollow" >下一页</a>
                    </c:when>
                    <c:when test="${usersPageInfo.pageNum + 1 >= usersPageInfo.total}">
                        <a href="queryPages?page=${usersPageInfo.total}" rel="external nofollow" rel="external nofollow" >下一页</a>
                    </c:when>
                </c:choose>
                <c:choose>
                    <c:when test="${usersPageInfo.total==0}">
                        <a href="queryPages?page=${usersPageInfo.pageNum}" rel="external nofollow" rel="external nofollow" >尾页</a>
                    </c:when>
                    <c:otherwise>
                        <a href="queryPages?page=${usersPageInfo.total}" rel="external nofollow" rel="external nofollow" >尾页</a>
                    </c:otherwise>
                </c:choose>
            </div>
        </div>
    </div>
</div>